
return {
    beforePreProcess: function (content, url) {
        //beforePreProcess 页面初始化之前，可在此进行模版修改 or 定义新的参数
       
    },
    beforePageInit: function (page) {
        var self = this
        self.tool.format= async function(products) {
            var self = this;
            let obj = {
                customer: cb.rest.appContext.context.agentId,
                deliveryMethod: '自提',
                receiveAddress: '',
                productDetail: [],
            }
            products.forEach(element => {
                let product = {
                  productCode: element.cCode,
                  productId: element.id,
                  org: element.saleOrgId,
                  priceQty: 1,
                  productUnitId: element.mainUnit.id,
                  currency: '1655486829428736015',
                  stockId: ''
                }
                obj.productDetail.push(product)
            });
            let getPrice= function() {
                return new Promise((resolve, reject) => {
                    cb.rest.postCross({
                        url: "https://saas.hlhs-bip.com/iuap-api-gateway/ajxbewdh/AcquisitionPrice/GetPriceAndFreight/pricing/acquisitionPrice?appKey=a4dc65b0fbab4f68a56e8054999a2ab3",
                        params: obj,
                        type:'post',
                        success: (res) => {
                            resolve(res.data)
                        },
                        error: function(errRes) {
                            console.log('errRes', errRes);
                        }
                    })
                })
            }
            let list = []
            if(products.length != 0) {
                list = await getPrice()
            }
            return Array.isArray(products) ? (products.map(function(item) {
                item.isShowCode = cb.FunctionOptions.QUICKORDERISSHOWPRODUCTCODE && item.cCode,
                item.isShowModelDescription = cb.FunctionOptions.PRODUCTSPECIFICATION && item.modelDescription,
                item.isShowModel = cb.FunctionOptions.PACKAGESPECIFICATIONS && item.model,
                item.showImage = cb.rest.appContext.showImage,
                item.isHidePrice = self.paramsContent.isHidePrice,
                item.hasPreSale = cb.FunctionOptions.OPENPRESALE && $$.isArray(item.lsPresales) && item.lsPresales.length,
                item.lsProductSkus = item.lsProductSkus || [],
                item.isValid = item.isValid && 0 !== item.iStatus,
                item.fSalePrice = upcommon.toThousands(list[item.id].price),
                item.iMinPrice = item.isHidePrice ? item.fSalePrice : upcommon.toThousands(item.iMinPrice || item.fSalePrice) || cb.FunctionOptions.PRODUCTPRICESHOW,
                item.isShowPrice = !cb.FunctionOptions.PRODUCTNOTSHOWPRICE,
                item.productTips = !0 === cb.FunctionOptions.ORDERINVENTORYCHECK && "NONE" != cb.FunctionOptions.INVENTORYDISPLAY && upcommon.showProductTips(item.productTip),
                0 < item.cName.indexOf("®") && (item.cName = item.cName.replace(lang.templateByUuid("UID:P_UDHMC_17EC591E05880756", "®"), lang.templateByUuid("UID:P_UDHMC_17EC591E05880757", "<sup>®</sup>")));
                var relation = upcommon.setCurrTypeSign(item);
                cb.rest.appContext.context.isAgent && cb.FunctionOptions.ORDERSHOWWAY && relation && 1 == relation.bizType && (item.bizName = -1 < [3, 4].indexOf(cb.rest.appContext.context.bizMode) ? item.orgName : cb.rest.appContext.context.corpName)
            }),
            products) : new Array
        }
        self.selector.productContainer.on("infinite",function() {
            if (self.temp.timeMark)
                return !1;
            self.temp.timeMark = setTimeout(function() {
                self.temp.timeMark = null;
                var lastIndex = parseInt(("list" == self.temp.listType ? self.selector.productListContainer.find("li") : self.selector.productBlockContainer.find(".col-50")).length / self.paramsContent.params.pageSize) + 1;
                self.paramsContent.params.currentPage < lastIndex && (self.paramsContent.params.currentPage = lastIndex,
                self.selector.infiniteScrollPreloader.show(),
                self.paramsContent.params.pageIndex = self.paramsContent.params.currentPage,
                self.paramsContent.params.serviceTab = self.context.serviceTab || 0,
                self.paramsContent.params.isEnd = self.context.isEnd || !1,
                cb.rest.getJSON({
                    url: self.paramsContent.serverUrl,
                    params: self.paramsContent.params,
                    success: async function(data) {
                        self.selector.infiniteScrollPreloader.hide(),
                        self.context.serviceTab = data.data.serviceTab,
                        self.context.isEnd = data.data.isEnd,
                        data.data || (data.data = {
                            totalCount: 0,
                            data: []
                        });
                        data = await self.tool.format.call(self, data.data.data);
                        self.temp.products.push.apply(self.temp.products, data),
                        !data || data.length < self.paramsContent.params.pageSize ? ($$(self.pageContainer).find(".list-continer").find("ul").parent().children(".page-bottom").removeClass("hide"),
                        self.selector.pageBottom.show()) : self.selector.pageBottom.hide(),
                        1 < self.paramsContent.params.currentPage && 0 != data.length && (self.selector.productListContainer.find("ul").append(self.tplListFunc({
                            serverhost: cb.rest.appContext.serviceUrl,
                            products: data,
                            isOpenMultOrginazation: cb.FunctionOptions.ORDERSHOWWAY && (2 == cb.rest.appContext.context.bizMode || 4 == cb.rest.appContext.context.bizMode)
                        })),
                        self.selector.productBlockContainer.append(self.tplBlockFunc({
                            serverhost: cb.rest.appContext.serviceUrl,
                            products: data,
                            isOpenMultOrginazation: cb.FunctionOptions.ORDERSHOWWAY && (2 == cb.rest.appContext.context.bizMode || 4 == cb.rest.appContext.context.bizMode)
                        })),
                        $$.each(self.selector.productContainer.find(".title-top"), function(index, item) {
                            3 <= item.children.length && (item.style.height = "auto",
                            item.style["margin-bottom"] = "5px")
                        }),
                        $$.each(self.selector.productContainer.find(".list-continer .upimgdiv"), function(index, item) {
                            var parentWidth = $$(item).parent().width();
                            $$(item).css({
                                width: parentWidth + "px",
                                height: parentWidth + "px"
                            })
                        })),
                        $$.each(self.selector.upimgdiv, function(index, item) {
                            var parentWidth = $$(item).parent().width();
                            $$(item).css({
                                width: parentWidth + "px",
                                height: parentWidth + "px"
                            })
                        }),
                        myApp.refreshScroller()
                    }
                }))
            }, 300)
        })
    },   
    afterPageInit: function (page) {
        // 该事件时  Dom已ready 但已执行当前页面固有逻辑
        console.log('lexus');
    },
    beforePageBack: function (page) {
        // 页面回退之前
    },
    afterPageBack: function (page) {
        // 页面回退之后
    },
};